﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace VideoCarousel.Entity
{
    internal class IntToImage : IValueConverter
    {
        System.Windows.Media.SolidColorBrush solidColorBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Black);
        System.Windows.Media.ImageBrush image;

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
             int type = (int)value;
            if (type == 0)
            {
                if (image == null)
                {
                    ImageBrush imageBrush = new ImageBrush();
                    imageBrush.ImageSource = new BitmapImage(new Uri(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bacground.jpg"), UriKind.Relative));
                    image = imageBrush;

                }
              
                return image;
            }
            else
            {
                return solidColorBrush;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return 0;
        }
    }
}
